home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / gems / g_gemsi.lha / GraphicsGems / PolyScan / poly.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-10  |  2.3 KB  |  77 lines

  1.  
  2. /*
  3.  * poly.c: simple utilities for polygon data structures
  4.  */
  5.  
  6. #include "poly.h"
  7.  
  8. Poly_vert *poly_dummy;    /* used superficially by POLY_MASK macro */
  9.  
  10. /*
  11.  * poly_print: print Poly p to stdout, prefixed by the label str */
  12.  
  13. void poly_print(str, p)
  14. char *str;
  15. Poly *p;
  16. {
  17.     int i;
  18.  
  19.     printf("%s: %d sides\n", str, p->n);
  20.     poly_vert_label("        ", p->mask);
  21.     for (i=0; i<p->n; i++) {
  22.         printf("   v[%d] ", i);
  23.         poly_vert_print("", &p->vert[i], p->mask);
  24.     }
  25. }
  26.  
  27.  
  28. void poly_vert_label(str, mask)
  29. char *str;
  30. int mask;
  31. {
  32.     printf("%s", str);
  33.     if (mask&POLY_MASK(sx))   printf("   sx  ");
  34.     if (mask&POLY_MASK(sy))   printf("   sy  ");
  35.     if (mask&POLY_MASK(sz))   printf("   sz  ");
  36.     if (mask&POLY_MASK(sw))   printf("   sw  ");
  37.     if (mask&POLY_MASK(x))    printf("   x   ");
  38.     if (mask&POLY_MASK(y))    printf("   y   ");
  39.     if (mask&POLY_MASK(z))    printf("   z   ");
  40.     if (mask&POLY_MASK(u))    printf("   u   ");
  41.     if (mask&POLY_MASK(v))    printf("   v   ");
  42.     if (mask&POLY_MASK(q))    printf("   q   ");
  43.     if (mask&POLY_MASK(r))    printf("   r   ");
  44.     if (mask&POLY_MASK(g))    printf("   g   ");
  45.     if (mask&POLY_MASK(b))    printf("   b   ");
  46.     if (mask&POLY_MASK(nx))   printf("   nx  ");
  47.     if (mask&POLY_MASK(ny))   printf("   ny  ");
  48.     if (mask&POLY_MASK(nz))   printf("   nz  ");
  49.     printf("\n");
  50. }
  51.  
  52. void poly_vert_print(str, v, mask)
  53. char *str;
  54. Poly_vert *v;
  55. int mask;
  56. {
  57.     printf("%s", str);
  58.     if (mask&POLY_MASK(sx)) printf(" %6.1f", v->sx);
  59.     if (mask&POLY_MASK(sy)) printf(" %6.1f", v->sy);
  60.     if (mask&POLY_MASK(sz)) printf(" %6.2f", v->sz);
  61.     if (mask&POLY_MASK(sw)) printf(" %6.2f", v->sw);
  62.     if (mask&POLY_MASK(x))  printf(" %6.2f", v->x);
  63.     if (mask&POLY_MASK(y))  printf(" %6.2f", v->y);
  64.     if (mask&POLY_MASK(z))  printf(" %6.2f", v->z);
  65.     if (mask&POLY_MASK(u))  printf(" %6.2f", v->u);
  66.     if (mask&POLY_MASK(v))  printf(" %6.2f", v->v);
  67.     if (mask&POLY_MASK(q))  printf(" %6.2f", v->q);
  68.     if (mask&POLY_MASK(r))  printf(" %6.4f", v->r);
  69.     if (mask&POLY_MASK(g))  printf(" %6.4f", v->g);
  70.     if (mask&POLY_MASK(b))  printf(" %6.4f", v->b);
  71.     if (mask&POLY_MASK(nx)) printf(" %6.3f", v->nx);
  72.     if (mask&POLY_MASK(ny)) printf(" %6.3f", v->ny);
  73.     if (mask&POLY_MASK(nz)) printf(" %6.3f", v->nz);
  74.     printf("\n");
  75. }
  76.  
  77.